package com.ljxt.dt.dao.purchasingmanagementdao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 结果集消费
 * @author 徐浩钦
 * @version 1.0.0
 * @date 2020/5/16 20:14
 * @copyright 老九学堂T11
 */
public interface ResultSetConsumers<T> {

    List<Object> rows = new ArrayList();

    default List<Object> getRows(){
        return rows;
    }

    default List<Object> getRows(boolean isClear){
        if(isClear){
            rowsClear();
        }
        return rows;
    }

    default void  rowsClear(){
        rows.clear();
    }

    /**
     * 申请
     * @param rs
     * @return
     * @throws SQLException
     */
    T apply(ResultSet rs, Map<String,Object> row) throws SQLException;

    /**
     * 接受
     * @param object
     */
    boolean accept(T object);
}
